﻿//  --------------------------------
//  Copyright (c) AW Systems, Inc. All rights reserved.
//  This source code is made available under the terms of the Microsoft Public License (Ms-PL)
//  http://www.codeplex.com/SLAM/license
//  ---------------------------------

using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Text;
using Slam;
using Slam.Activation;
using Slam.Configuration;
using Slam.Data;
using Slam.Events;
using Slam.Logging;
using Slam.SharePoint;
using StructureMap;
using StructureMap.Attributes;
using StructureMap.Configuration.DSL;
using StructureMap.Pipeline;


namespace Slam.StructureMap
{
	public class SlamRegistry : Registry
	{
		public SlamRegistry()
		{
			if (ConfigurationManager.AppSettings["Slam.ConfigurationManager.Config"] != null || ConfigurationManager.AppSettings["AWS.SLAM.ConfigurationManager.Config"] != null)
			{
				For<IConfigurationManager>().Singleton().Use<XmlConfigurationManager>()
					.Ctor<string>("configurationLocation").Is(ConfigurationManager.AppSettings["Slam.ConfigurationManager.Config"] ?? ConfigurationManager.AppSettings["AWS.SLAM.ConfigurationManager.Config"]);
			}
			else
			{
				For<IConfigurationManager>().Singleton().Use(new XmlConfigurationManager());
			}

			For<IDataServices>().Use<SqlDataServices>();
			For<ILogger>().Use<SqlLogger>();
			For<IDataSynchronizer>().Use<DataSynchronizer>();
			For<IDataSynchronizeTypeProcessor>().Use<SqlDataSynchronizeTypeProcessor>();
			For<IActivator>().Use<Activator>();
			For<IListItemExtensions>().Use<DefaultListItemExtensions>();
		}
	}
}
